/**
 * Created by coolxu on 2017/12/11.
 */
    //此js用于manager.html的交互
    //将各自负责的部分，使用controller控制
    var managerApp = angular.module('managerApp', []);

managerApp.controller('complainMangementCtrl',function($scope,$http){

    $scope.unhandledComplaintListShow = true;
    $scope.handledComplaintListShow = false;

    //默认显示未处理投诉

    $http({
        method: 'GET',
        url: 'http://localhost:8080/checkComplaintList'
    }).then(
        function successback(data) {
            console.log(data);
            $scope.complains = data.data.data;
            console.log($scope.complains);

        }, function errorback() {
            console.log("fail");
            jError("获取投诉列表出错！", {
                VerticalPosition: 'center',
                HorizontalPosition: 'center'
            });
        }
    );


    //投诉删除
$scope.delete=function(complain){
    console.log(complain.jobnumber);

    var sure = confirm("确认要删除吗，删除后不可恢复！");
    if(sure){
        $http({
            method: 'GET',
            url: 'http://localhost:8080/deleteComplaint/'+complain.jobnumber
        }).then(
            function successback(data) {
                console.log(data);
                $scope.complains = data.data.data;
                alert("删除投诉成功");
            }, function errorback() {
                console.log("fail");
                jError("删除投诉出错！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        )
    }
};

    //投诉归档
$scope.file=function(complain){
    $http({
        method: 'post',
        url: 'http://localhost:8080/endWorkOrder',
        data:{'jobnumber':complain.jobnumber}
    }).then(
        function successback(data) {
            console.log(data);
            $scope.complains = data.data.data;
            console.log($scope.complains);
            alert("归档投诉成功");
        }, function errorback() {
            console.log("fail");
            jError("投诉归档出错！", {
                VerticalPosition: 'center',
                HorizontalPosition: 'center'
            });
        }
    )
};


    $http({
        method: 'GET',
        url: 'http://localhost:8080/findComplaintAndIspigeonhole'
    }).then(
        function successback(data) {
            $scope.handcomplains = data.data.data;
            console.log(data);
        }, function errorback() {
            console.log("fail");
            jError("获取投诉列表出错！", {
                VerticalPosition: 'center',
                HorizontalPosition: 'center'
            });
        }
    );

  $scope.unhandledComplaints = function(){
      $scope.unhandledComplaintListShow = true;
      $scope.handledComplaintListShow = false;


      $http({
          method: 'GET',
          url: 'http://localhost:8080/checkComplaintList'
      }).then(
          function successback(data) {
              console.log(data);
              $scope.complains = data.data.data;
              console.log($scope.complains);

          }, function errorback() {
              console.log("fail");
              jError("获取投诉列表出错！", {
                  VerticalPosition: 'center',
                  HorizontalPosition: 'center'
              });
          }
      );

  };

    $scope.handledComplaints = function(){
        $scope.unhandledComplaintListShow = false;
        $scope.handledComplaintListShow = true;

        $http({
            method: 'GET',
            url: 'http://localhost:8080/findComplaintAndIspigeonhole'
        }).then(
            function successback(data) {
                $scope.handcomplains = data.data.data;
                console.log(data);
            }, function errorback() {
                console.log("fail");
                jError("获取投诉列表出错！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        );
    }
    });

    //创建工单交互结开始
    managerApp.controller('createCtrl',function($scope,$http) {
    //填写工单号，自动补全教师信息
    //    设置controller中的全局变量
        $scope.teacherinfo = {
            gh: '0000969',//教师工号
            postion:null,//职位
            name: null,//教师姓名
            phone: null,//教师电话
            dept:null//教师地址
        };
    $scope.create_getuserinfo = function () {

        $http({
            method: 'GET',
            dataType:"json",
            url: 'http://localhost:8080/getTeacherInfo/'+ $scope.teacherinfo.gh,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}

        }).then(
            function successback(data) {
                $scope.teacherinfo = JSON.parse(data.data.data);
                console.log(data);
            }, function errorback() {
                console.log("fail");
                jError("获取教师信息出错！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        )
    };


    //获取故障分类开始
    $http({
        method: 'GET',
        url: 'http://localhost:8080/OneLevelDirectories'
    }).then(
        function successback(data) {
            //创建一个数组来装获取到的故障
            $scope.ques = new Array();
            console.log(data.data.data.data);

            for(var i=0;i<data.data.data.data.length;i++){
                $scope.ques[i]=data.data.data.data[i].one;
            }

        }, function errorback(res) {
            console.log("fail--------" + res);
            jError("获取故障分类出错，请重试！", {
                VerticalPosition: 'center',
                HorizontalPosition: 'center'
            });
        }
    );
        //获取故障分类结束

        //设置一个变量来保存故障的值
        $scope.chooseque = "";
        //    //当管理员选择了故障之后获取故障
            $scope.chooseques = function(){
                //选中的值赋值给变量
                $scope.chooseque = $scope.selectques;
                console.log($scope.chooseque);
            };


    //点击提交按钮，管理员创建工单
    $scope.managersubmit=function(){
        console.log($scope.chooseque);
        //$scope.createinfo = {
        //    details: $scope.chooseque,
        //    address:$scope.teacherinfo.dept,
        //    type:1,
        //    userAccount:$scope.teacherinfo.gh
        //};
        $scope.createinfo = {
            details: "网络",
            address:"我是默认地址",
            type:1,
            userAccount:"1506101070"
        };
        $http({
            method: 'POST',
            url: 'http://localhost:8080/addWorkOrder',
            data:$scope.createinfo
        }).then(
            function successback(data) {
                console.log(data);
                jSuccess("创建工单成功！正在派单...",{
                        VerticalPosition: 'center',
                        HorizontalPosition: 'center'
                    }
                );

                //创建工单成功后，给运维人员发送短信
                $scope.operators = {
                    phone:data.data.data.userPhone,
                    content:"亲爱的运维人员"+data.data.data.userName+"您接到一个工单，请尽快处理！",
                    username:null,//短信接口用户名
                    password:null//短信接口密码
                };
                $http({
                    method:"get",
                    url:"http://172.16.10.80:8085/SendMessage.aspx?phone=13666140399&content="+ $scope.operators.content+"&username=lyityw&password=ityw_2017",
                    data:$scope.operators,
                    header:'Access-Control-Allow-Headers:x-requested-with,content-type'
                }).then(
                    function successback(){
                        jSuccess("派单成功！",{
                            VerticalPosition: 'center',
                            HorizontalPosition: 'center'
                        })
                    },function errorback(){
                        jSuccess("派单成功！",{
                            VerticalPosition: 'center',
                            HorizontalPosition: 'center'
                        })
                    }
                )
            }, function errorback(response) {
                console.log("fail"+response.toString());
                jError("创建工单失败！请重试！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        )
    };


});
//创建工单交互结束

//工单管理交互开始
    managerApp.controller('ticketmanageCtrl',function($scope,$http) {




        //默认显示未处理的工单
        $scope.unticketManagementShowValue = true;
        $scope.ticketManagementShowValue = false;



        $scope.unticketmanageparams={
            //IsDistribution:1, //是否分单
            //IsReceive:1, //运维是否接收
            isComplete:0  //运维是否完成
            //isPigeonhole:0, //是否归档
            //iscomment:0 //是否评论
        };
        $http({
            method: 'POST',
            url: 'http://localhost:8080/queryScheduleOfWorkOrders',
            data:$scope.unticketmanageparams
        }).then(
           function successback(data){
               console.log(data);
               $scope.unmanagetickets=data.data.data;
           },function errorback(res){
                console.log("fail"+res);
                jError("获取未处理的工单失败！请重试！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        );


        //点击未处理的工单，显示
        $scope.managenotresolve=function(){
            $scope.ticketManagementShowValue = false;
            $scope.unticketManagementShowValue = true;




            $http({
                method: 'POST',
                url: 'http://localhost:8080/queryScheduleOfWorkOrders',
                data:$scope.unticketmanageparams
            }).then(
                function successback(data){
                    console.log(data);
                    $scope.unmanagetickets=data.data.data;
                },function errorback(res){
                    console.log("fail"+res);
                    jError("获取未处理的工单失败！请重试！", {
                        VerticalPosition: 'center',
                        HorizontalPosition: 'center'
                    });
                }
            );
        };


        //点击已完成的工单，显示
        $scope.manageresolve=function(){

            $scope.ticketManagementShowValue = true;
            $scope.unticketManagementShowValue = false;

            $scope.ticketmanageparams={
                //IsDistribution:1, //是否分单
                //IsReceive:1, //运维是否接收
                isComplete:1 //运维是否完成
                //isPigeonhole:1, //是否归档
                //iscomment:1 //是否评论
            };
            $http({
                method: 'POST',
                url: 'http://localhost:8080/queryScheduleOfWorkOrders',
                data:$scope.ticketmanageparams
            }).then(
                function successback(data){
                    console.log(data);
                    $scope.managetickets=data.data.data;
                },function errorback(){
                    console.log("fail");
                    jError("获取已处理的工单失败！请重试！", {
                        VerticalPosition: 'center',
                        HorizontalPosition: 'center'
                    });
                }
            );
        };

        //工单内的删除按钮
        $scope.deleteTicket = function(manageticket){

            console.log(manageticket);

            var sure = confirm("确认要删除吗，删除后不可恢复！");
            if(sure){

                $http({
                    method: 'POST',
                    url: 'http://localhost:8080/deleteWorkOrder',
                    data:manageticket
                }).then(
                    function successback(data){
                       alert("删除成功");
                    },function errorback(){

                        jError("删除工单失败！请重试！", {
                            VerticalPosition: 'center',
                            HorizontalPosition: 'center'
                        });
                    }
                );
            }
        }
});
//工单管理交互结束

//故障分类管理交互开始
managerApp.controller('managerFaultCtrl',function($scope,$http){
    $scope.oType = null;
    $scope.oneLevelDirectory = {
        one:null,
        oType:null,
        updateOne:null,
        userName:null,
        userPhone:null
    };
    $scope.userInfo = {
        userType:null,
        userName:null
    };
    //得到一级目录
    $http({
        method: 'get',
        url: 'http://localhost:8080/OneLevelDirectories'
    }).then(function successback(resp){
            $scope.oneLevel=resp.data.data.data;
        },function errorback(resp){
            console.log("fail");
        }
    );
    //修改一级目录
    $scope.get = function (id) {
        var myId = "#"+id;
        $scope.oneLevelDirectory.one = $(myId).val();
    };
    $scope.getUser = function (id) {
        var myId2 = "#"+id;
        $scope.oneLevelDirectory.userPhone = $(myId2).val()
    };
    $scope.updateOne=function(id,id1){
        var myId1 = "#"+id;
        var myId3 = "#"+id1;
        console.log("现1"+$(myId1).val());
        console.log("原1"+$scope.oneLevelDirectory.one);
        console.log("现2"+$(myId3).val());
        console.log("原2"+$scope.oneLevelDirectory.userPhone);
        console.log("1"+($(myId1).val() != $scope.oneLevelDirectory.one && $scope.oneLevelDirectory.userPhone==null && $scope.oneLevelDirectory.one!=null)+"+"+($(myId1).val() != $scope.oneLevelDirectory.one && $(myId3).val()==$scope.oneLevelDirectory.userPhone));
        console.log("2"+($(myId3).val() != $scope.oneLevelDirectory.userPhone && $scope.oneLevelDirectory.one==null && $scope.oneLevelDirectory.userPhone!=null)+"+"+($(myId3).val() != $scope.oneLevelDirectory.userPhone && $(myId1).val()==$scope.oneLevelDirectory.one));
        console.log("3"+( $scope.oneLevelDirectory.userPhone==null && $scope.oneLevelDirectory.one==null)+"+"+($(myId3).val() == $scope.oneLevelDirectory.userPhone && $(myId1).val()==$scope.oneLevelDirectory.one));
        alert(($scope.oneLevelDirectory.userPhone!=null && $scope.oneLevelDirectory.one!=null && $(myId3).val() != $scope.oneLevelDirectory.userPhone && $(myId1).val()!=$scope.oneLevelDirectory.one));
        if (($(myId1).val() != $scope.oneLevelDirectory.one && $scope.oneLevelDirectory.userPhone==null && $scope.oneLevelDirectory.one!=null)
            ||($(myId1).val() != $scope.oneLevelDirectory.one && $(myId3).val()==$scope.oneLevelDirectory.userPhone)){
            $scope.oneLevelDirectory.updateOne = $(myId1).val();
            $http({
                method: 'put',
                url: 'http://localhost:8080/levelDirectories',
                data: $scope.oneLevelDirectory
            }).then(function successback(resp){
                $scope.oneLevelDirectory.userPhone=null;
                $scope.oneLevelDirectory.one = null;
                $scope.oneLevelDirectory.updateOne = null;
                location.reload();
                alert("成功！")
                },function errorback(resp){
                    console.log("fail");
                }
            );
            alert("1修改")
        }else if(($(myId3).val() != $scope.oneLevelDirectory.userPhone && $scope.oneLevelDirectory.one==null && $scope.oneLevelDirectory.userPhone!=null)
            ||($(myId3).val() != $scope.oneLevelDirectory.userPhone && $(myId1).val()==$scope.oneLevelDirectory.one)){

            $scope.userInfo.userName = $(myId3).val();
            $http({
                method: 'get',
                url: 'http://localhost:8080/selectOType/'+$(myId1).val()
            }).then(function successback(resp){
                $scope.userInfo.userType = resp.data.data.oType;
                console.log(resp.data.data);
                $http({
                    method: 'post',
                    url: 'http://localhost:8080/updateTypeByUserName',
                    data: $scope.userInfo
                }).then(function successback(resp){
                        $scope.oneLevelDirectory.userPhone;
                        $scope.oneLevelDirectory.one = null;
                        $scope.oneLevelDirectory.updateOne = null;
                    $scope.userInfo.userType=null;
                    $scope.userInfo.userName=$scope.oneLevelDirectory.userPhone;
                    $http({
                        method: 'post',
                        url: 'http://localhost:8080/updateTypeByUserName',
                        data: $scope.userInfo
                    }).then(function successback(resp){
                            $scope.oneLevelDirectory.userPhone;
                            $scope.oneLevelDirectory.one = null;
                            $scope.oneLevelDirectory.updateOne = null;
                            $scope.userInfo.userType=null;
                            $scope.userInfo.userName=null;
                            location.reload();
                            alert("成功！")

                        },function errorback(resp){
                            console.log("fail");
                        }
                    );

                    },function errorback(resp){
                        console.log("fail");
                    }
                );
                },function errorback(resp){
                    console.log("fail");
                }
            );
            alert("2修改")
        }else if(( $scope.oneLevelDirectory.userPhone==null && $scope.oneLevelDirectory.one==null)
            ||($(myId3).val() == $scope.oneLevelDirectory.userPhone && $(myId1).val()==$scope.oneLevelDirectory.one)){
            $scope.oneLevelDirectory.userPhone=null;
            $scope.oneLevelDirectory.one = null;
            $scope.oneLevelDirectory.updateOne = null;
            alert("没修改")
            location.reload();
        }else if(($scope.oneLevelDirectory.userPhone!=null && $scope.oneLevelDirectory.one!=null && $(myId3).val() != $scope.oneLevelDirectory.userPhone && $(myId1).val()!=$scope.oneLevelDirectory.one)){
            $scope.oneLevelDirectory.userPhone=null;
            $scope.oneLevelDirectory.one = null;
            $scope.oneLevelDirectory.updateOne = null;
            alert("都修改")

        }

    };
    //删除一级目录
    $scope.deleteOne=function(id){
        var myId4 = "#"+id;
        $scope.oneLevelDirectory.one = $(myId4).val();
        $http({
            method: 'post',
            url: 'http://localhost:8080/deleteLevelDirectories',
            data: $scope.oneLevelDirectory
        }).then(function successback(resp){
                $scope.oneLevelDirectory.one = null;
                alert("删除成功!");
                location.reload();
            },function errorback(resp){
                console.log("fail");
            }
        );
    };
    //添加级目录
    $scope.add=function(){
           alert($scope.oneLevelDirectory.userName+"+"+$scope.oneLevelDirectory.one);
            $http({
                method: 'post',
                url: 'http://localhost:8080/levelDirectories',
                data: $scope.oneLevelDirectory
            }).then(function successback(resp){
                $scope.userInfo.userName = $scope.oneLevelDirectory.userName;
                $scope.userInfo.userType = resp.data.data.data-1;
                $http({
                    method: 'post',
                    url: 'http://localhost:8080/updateTypeByUserName',
                    data: $scope.userInfo
                }).then(function successback(resp){
                        $scope.oneLevelDirectory.one = null;
                        $scope.userInfo.userType=null;
                        $scope.userInfo.userName=null;
                        alert("成功！")
                    },function errorback(resp){
                        console.log("fail");
                    }
                );
                    $("#addKind").css("display","none");
                    $scope.oneLevelDirectory.one = null;
                },function errorback(resp){
                    console.log("fail");
                }
            );
    }
});
//故障分类管理交互结束

//工单统计报表交互开始
    managerApp.controller('totalworkCtrl', function ($scope, $http) {
        //将时间写在外面，之后可以用
        var now = new Date();
        var currentyear = now.getFullYear();
        //时间写死，从今年倒数三年
        $scope.times = [
            {ttt: currentyear},
            {ttt: currentyear - 1},
            {ttt: currentyear - 2}
        ];

        $scope.selecttime = $scope.times[0];//使得默认显示最新年
        console.log($scope.selecttime.ttt);
        //默认显示最新年的数据
        $http({
            method: 'POST',
            url: 'http://localhost:8080/queryMonthWorkOrders',
            data: {'year':$scope.selecttime.ttt}
        }).then(
            function successback(data) {
                $scope.deaprttotalwork = data.data.data;
            }, function errorback(res) {
                console.log("fail--------");
                console.log(res);
                jError("获取工单统计报表数据出错，请重试！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        );


        //根据部门查询
    $scope.querybydepart = function () {
        //console.log($scope.selecttime);

                $http({
                    method: 'POST',
                    url: 'http://localhost:8080/queryMonthWorkOrders',
                    data:{'year':$scope.selecttime.ttt}
                }).then(
                    function successback(data) {
                        $scope.deaprttotalwork = data.data.data;
                        console.log(data.data);
                    }, function errorback(res) {
                        console.log("fail--------" + res);
                        jError("获取工单统计报表数据出错，请重试！", {
                            VerticalPosition: 'center',
                            HorizontalPosition: 'center'
                        });
                    }
                );
    };

        //根据故障查询
    $scope.querybyfault = function () {
                $http({
                    method: 'POST',
                    url: 'http://localhost:8080/queryMonthWorkOrdersByDetails',
                    data:{'year':$scope.selecttime.ttt}
                }).then(
                    function successback(data) {
                        console.log(data);
                        $scope.faulttotalwork = data.data.data;
                    }, function errorback(res) {
                        console.log("fail--------" + res);
                        jError("获取工单统计报表数据出错，请重试！", {
                            VerticalPosition: 'center',
                            HorizontalPosition: 'center'
                        });
                    }
                )
    };
    });
//    //工单统计报表交互结束


//    //运维人员业绩交互开始
    managerApp.controller('performanceCtrl',function($scope,$http) {
        //将时间写在外面，之后可以用
        var now = new Date();
        var currentyear = now.getFullYear();
        //时间写死，从今年倒数三年
        $scope.times = [
            {ttt: currentyear},
            {ttt: currentyear - 1},
            {ttt: currentyear - 2}
        ];
        $scope.selecttime = $scope.times[0];//使得默认显示最新年
        //默认显示最新年的数据
        $http({
            method: 'POST',
            url: 'http://localhost:8080/queryITMonthWorkOrders',
            data:  {'year':$scope.selecttime.ttt}

        }).then(
            function successback(data) {
                $scope.performancetoper = data.data.data;
                console.log(data);
            }, function errorback(res) {
                console.log("fail--------" + res);
                jError("获取运维人员业绩出错，请重试！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        );

        //根据业绩查询
    $scope.querybyperformance=function(){
                $http({
                    method: 'POST',
                    url: 'http://localhost:8080/queryITMonthWorkOrders',
                    data: {'year':$scope.selecttime.ttt}
                }).then(
                    function successback(data) {
                        $scope.performancetoper = data.data.data;
                        console.log(data);
                    }, function errorback(res) {
                        console.log("fail--------" + res);
                        jError("获取运维人员业绩出错，请重试！", {
                            VerticalPosition: 'center',
                            HorizontalPosition: 'center'
                        });
                    }
                )
    };

        //根据星级查询
    $scope.querybystar=function(){
        $http({
            method: 'GET',
            url: 'http://localhost:8080/countComplaintAndStar'
        }).then(
            function successback(data) {
                $scope.perstar = data.data.data;
                console.log(data);
            }, function errorback(res) {
                console.log("fail--------" + res);
                jError("获取运维人员星级出错，请重试！", {
                    VerticalPosition: 'center',
                    HorizontalPosition: 'center'
                });
            }
        )
        }

    });

    //运维人员业绩交互结束


//运维人员管理   开始
managerApp.controller('operlistCtrl', function($scope, $http) {

    var operadddiv = document.getElementById("operadddiv");
//点击添加按钮,弹出添加运维人员的框
    $scope.addoperlist = function(){
        operadddiv.style.display = "block";
    };
    //点击取消按钮，隐藏添加运维人员的框
    $scope.canceladdoperbtn = function(){
        operadddiv.style.display = "none";
    }

});
//运维人员管理   结束

//网站管理交互开始
managerApp.controller('siteCtrl', function($scope, $http) {
    //获取服务电话
    $http({
        method: 'GET',
        url: 'http://localhost:8080/webServiceInfo'
    }).then(function successCallback(data) {
        $scope.servicephone = data.data.data.content;
        //console.log(data.data.data);
    }, function errorCallback(response) {
        // 请求失败执行代码
        console.log(response);
        jError("获取服务电话出错，请重试！", {
            VerticalPosition: 'center',
            HorizontalPosition: 'center'
        });
    });

//点击修改
    $scope.alterservicephone=function(){
        $http({
            method: 'POST',
            url: 'http://localhost:8080/webServiceInfo',
            data:{'Name':'服务电话','Content':$scope.servicephone}
    }).then(function successCallback(data) {
            jSuccess("修改服务电话成功！请刷新页面！",{
                VerticalPosition: 'center',
                HorizontalPosition: 'center'
            });
        }, function errorCallback(response) {
            // 请求失败执行代码
            console.log(response);
            jError("修改服务电话出错，请重试！", {
                VerticalPosition: 'center',
                HorizontalPosition: 'center'
            });
        });
    }

});

//网站管理交互结束

//左边操作栏，服务电话显示交互开始
managerApp.controller('servicenumCtrl', function($scope, $http) {
    //获取服务电话
    $http({
        method: 'GET',
        url: 'http://localhost:8080/webServiceInfo'
    }).then(function successCallback(data) {
        $scope.servicephone = data.data.data.content;
        console.log(data.data.data);
    }, function errorCallback(response) {
        // 请求失败执行代码
        console.log(response);
        jError("获取服务电话出错，请重试！", {
            VerticalPosition: 'center',
            HorizontalPosition: 'center'
        });
    });
});
//左边操作栏，服务电话显示交互结束


<!--时间过滤-->

var dateDiff = function (timestamp) {

    //console.log(timestamp);

    // 补全为13位 为空则会显示刚刚
    var arrTimestamp = (timestamp + '').split('');
    for (var start = 0; start < 13; start++) {
        if (!arrTimestamp[start]) {
            arrTimestamp[start] = '0';
        }
    }
    timestamp = arrTimestamp.join('') * 1;

    var minute = 1000 * 60;
    var hour = minute * 60;
    var day = hour * 24;
    var halfamonth = day * 15;
    var month = day * 30;
    var now = new Date().getTime();
    var diffValue = now - timestamp;

    // 如果本地时间反而小于变量时间
    if (diffValue < 0) {
        return '不久前';
    }

    // 计算差异时间的量级
    var monthC = diffValue / month;
    var weekC = diffValue / (7 * day);
    var dayC = diffValue / day;
    var hourC = diffValue / hour;
    var minC = diffValue / minute;

    // 数值补0方法
    var zero = function (value) {
        if (value < 10) {
            return '0' + value;
        }
        return value;
    };

    // 使用
    if (monthC > 12) {
        // 超过1年，直接显示年月日
        return (function () {
            var date = new Date(timestamp);
            return date.getFullYear() + '年' + zero(date.getMonth() + 1) + '月' + zero(date.getDate()) + '日';
        })();
    } else if (monthC >= 1) {
        return parseInt(monthC) + "月前";
    } else if (weekC >= 1) {
        return parseInt(weekC) + "周前";
    } else if (dayC >= 1) {
        return parseInt(dayC) + "天前";
    } else if (hourC >= 1) {
        return parseInt(hourC) + "小时前";
    } else if (minC >= 1) {
        return parseInt(minC) + "分钟前";
    }
    return '时间为空';
};




managerApp.filter('newtime', function () {
    return function (input) {


        input = dateDiff(input);

        //alert(input);

        return input;
    }

});
managerApp.filter('reverse', function() {
    return function(text) {

        var txt = null;
        if(text != null){
            txt=text
        }else {
            txt="未完成"
        }
        return txt;
    }
});
managerApp.filter('reverse2', function() {
    return function(text) {

        var comments = [];

        if(text.commentContent==null){
            comments = text;

        }
        return comments;
    }
});
managerApp.filter('isnull',function(){
    return function(text) {

        var txt = null;
        if(text != null){
            txt=text
        }else {
            txt=0
        }
        return txt;
    }

});


managerApp.filter('wordStatus', function () {
    return function (input) {

        if(input==1){
            input="已完成";
        }else{
            input="未完成";
        }

        return input;
    }

});